/*
 * Copyright 2020 HPB Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hpb.bc.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;

import com.hpb.bc.entity.Addrs;
import com.hpb.bc.entity.BlockAddrs;
import com.hpb.bc.example.BlockAddrsExample;

public interface BlockAddrsMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table block_addrs_9
     *
     * @mbg.generated
     */
    long countByExample(BlockAddrsExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table block_addrs_9
     *
     * @mbg.generated
     */
    int deleteByExample(BlockAddrsExample example);


    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table block_addrs_9
     *
     * @mbg.generated
     */
    int insert(BlockAddrs record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table block_addrs_9
     *
     * @mbg.generated
     */
    int insertSelective(BlockAddrs record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table block_addrs_9
     *
     * @mbg.generated
     */
    List<BlockAddrs> selectByExampleWithBLOBs(BlockAddrsExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table block_addrs_9
     *
     * @mbg.generated
     */
    List<BlockAddrs> selectByExample(BlockAddrsExample example);


    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table block_addrs_9
     *
     * @mbg.generated
     */
    int updateByExampleSelective(@Param("record") BlockAddrs record, @Param("example") BlockAddrsExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table block_addrs_9
     *
     * @mbg.generated
     */
    int updateByExampleWithBLOBs(@Param("record") BlockAddrs record, @Param("example") BlockAddrsExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table block_addrs_9
     *
     * @mbg.generated
     */
    int updateByExample(@Param("record") BlockAddrs record, @Param("example") BlockAddrsExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table block_addrs_9
     *
     * @mbg.generated
     */
    int updateByPrimaryKeySelective(BlockAddrs record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table block_addrs_9
     *
     * @mbg.generated
     */
    int updateByPrimaryKeyWithBLOBs(BlockAddrs record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table block_addrs_9
     *
     * @mbg.generated
     */
    int updateByPrimaryKey(BlockAddrs record);

    /**
     * 查询总的交易记录数
     */
    int getTotalTransactionNumber();

    /***
     *  查询当前页总交易记录数目
     */
    int selectSumTxCountPerPage(@Param("blockNumber") Long blockNumber, @Param("startStepNumber") Integer pageNum, @Param("pageSize") Integer pageSize);

    /***
     *  根据当前页,每页数目，起点区块号 获取指定区块以下的页的区块BlockAddrs信息
     * @param  blockNumber 指定区块号，
     * @param  pageNum  当前页
     * @param pageSize 每页数目
     */
    List<BlockAddrs> selectPageBlockAddrs(@Param("blockNumber") Long blockNumber, @Param("startStepNumber") Integer pageNum, @Param("pageSize") Integer pageSize);

    /**
     * 根据参数查询
     *
     * @param blockAddrs
     */
    List<BlockAddrs> selectPageBlockAddrsUnderBlockNumber(@Param("blockAddrs") BlockAddrs blockAddrs);

    /**
     * 根据起止区块，终止区块，查询该区块（闭区间）区间下的有交易的区块列表；
     *
     * @param addrs
     */
    List<BlockAddrs> selectBlockAddrsListFromStartBlockToEndBlock(@Param("addrs") Addrs addrs, @Param("underBlockNumber") Long underBlockNumber);


    /**
     * 根据参数查询
     *
     * @param blockAddrs
     */
    List<BlockAddrs> selectBlockAddrsListBetweenStartBlockAndEndBlock(@Param("blockAddrs") BlockAddrs blockAddrs, @Param("startBlockNumber") Long startBlockNumber, @Param("endBlockNumber") Long endBlockNumber);

    /**
     * 查询underBlockNumber区块下，pageSize 条blockAddrs;
     *
     * @param pageSizeAmount,underBlockNumber
     */
    List<BlockAddrs> selectBlockAddrsListOfPageSizeCount(@Param("pageSizeAmount") Integer pageSizeAmount, @Param("underBlockNumber") Long underBlockNumber);

    /**
     * 获取默认pageSize(20)条,blockAddrs 的list;
     */
    List<BlockAddrs> selectPageBlockAddrsListOfPageSizeCountByDescType(@Param("pageSizeAmount") Integer pageSizeAmount, @Param("underBlockNumber") Long underBlockNumber, @Param("descType") String descType);

    /**
     * 获取默认pageSize(20)条,blockAddrs 的list;交易总数目；
     */
    Integer selectSumTxOfPageBlockAddrsListOfPageSizeCountByDescType(@Param("pageSizeAmount") Integer pageSizeAmount, @Param("underBlockNumber") Long underBlockNumber, @Param("descType") String descType);


    /**
     * 根据参数查询
     *
     * @param
     */
    List<BlockAddrs> selectBlockAddrsListBiggerThanBlockNumberAndLimitNByDescType(@Param("targetBlockNumber") Long targetBlockNumber, @Param("underBlockNumber") Long underBlockNumber, @Param("limitAmount") Integer limitAmount, @Param("descType") String descType);


    /**
     * 根据参数查询
     *
     * @param
     */
    List<BlockAddrs> selectBlockAddrsListSmallerThanBlockNumberAndLimitNByDescType(@Param("targetBlockNumber") Long targetBlockNumber, @Param("limitAmount") Integer limitAmount, @Param("descType") String descType);

    /**
     * 统计交易总数目；
     */
    Integer selectSumTxAmountInList(@Param("blockAddrsList") List<BlockAddrs> blockAddrsList);


    /**
     * limtCount  取多少条
     */
    List<BlockAddrs> selectBlockAddrsListIndexOfAddressBiggerThanByLimitCountAndDescType(@Param("underBlockNumber") Long underBlockNumber, @Param("targetBlockNumber") Long targetBlockNumber, @Param("limitAmount") Integer limitAmount, @Param("hexAddressNumber") String hexAddressNumber, @Param("descType") String descType);


    List<BlockAddrs> selectBlockAddrsListIndexOfAddressSmallerThanByLimitCountAndDescType(@Param("targetBlockNumber") Long targetBlockNumber, @Param("limitAmount") Integer limitAmount, @Param("hexAddressNumber") String hexAddressNumber, @Param("descType") String descType);


    /**
     * 根据起止区块，终止区块区间下的该账户的BlockAddrs
     *
     * @param hexAddressNumber
     */
    List<BlockAddrs> selectBlockAddrsListFromStartBlockToEndBlockOfTheAddrs(@Param("hexAddressNumber") String hexAddressNumber);

}